package com.bjdd.jdy.ui.feedback;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.bjdd.jdy.R;
import com.bjdd.jdy.base.BaseActivity;
import com.bjdd.jdy.entity.FeedBack;
import com.bjdd.jdy.util.SpUtil;
import com.bjdd.jdy.util.StatusBarUtil;
import com.bjdd.jdy.util.T;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FeedBackActivity extends BaseActivity<FeedBackPresenter, FeedBackModel> implements FeedBackContract.View {


    @Bind(R.id.toolbar_back)
    ImageView toolbarBack;
    @Bind(R.id.title)
    TextView title;
    @Bind(R.id.tv_toolbar_right)
    TextView tvToolbarRight;
    @Bind(R.id.et_feedback_content)
    EditText etFeedbackContent;

    @Override
    public int getLayoutId() {
        return R.layout.activity_feed_back;
    }

    @Override
    public void initView() {
        StatusBarUtil.setColor(this, getResources().getColor(R.color.toolbar_bg), 0);
        title.setText("意见反馈");
        tvToolbarRight.setText("提交");
        tvToolbarRight.setTextColor(getResources().getColor(R.color.text_black));
        tvToolbarRight.setVisibility(View.VISIBLE);
    }


    @OnClick({R.id.toolbar_back, R.id.tv_toolbar_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.toolbar_back:
                finish();
                break;
            case R.id.tv_toolbar_right:
                String content = etFeedbackContent.getText().toString();
                if (TextUtils.isEmpty(content) || content.equals("")){
                    T.show("内容不能为空");
                    return;
                }
                FeedBack feedBack = new FeedBack();
                feedBack.setMobile(SpUtil.getUser().getMobile());
                feedBack.setContent(content);
                feedBack.setType(0);
                feedBack.setUserId(SpUtil.getUser().getCarrierId());
                presenter.feedBack(feedBack,content);
                break;
        }
    }

    @Override
    public void feedBackSuccess() {
        finish();
    }
}
